/*
 * @Author: Mainul Islam
 */

package edu.uta.cse.randomgraph;

import java.text.DecimalFormat;

import edu.uta.cse.randomgraph.graph.ErdosRenyiGraph;
import edu.uta.cse.randomgraph.graph.MyGraph;
import edu.uta.cse.randomgraph.graph.PrefAttachGraph;
import edu.uta.cse.randomgraph.graph.ScaleFreeBAGraph;
import edu.uta.cse.randomgraph.graph.ScaleFreeDeterministicGraph;
import edu.uta.cse.randomgraph.gui.MyJPanel;
import edu.uta.cse.randomgraph.util.LogType;
import edu.uta.cse.randomgraph.util.LogWriter;


public class RandomGraph extends javax.swing.JFrame {

	private static final long serialVersionUID = 1L;
	
	/** Creates new form RandomGraph */
    public RandomGraph() {
        initComponents();
    }

  
    private void Tab1Gui() {
    	
        jPanelTab1 = new javax.swing.JPanel();
        jLabelNumNodes1 = new javax.swing.JLabel();
        jTextFieldNumNodes1 = new javax.swing.JTextField();
        jLabelConProb1 = new javax.swing.JLabel();
        jTextFieldConProb1 = new javax.swing.JTextField();
        jButtonGenGraph1 = new javax.swing.JButton();
        jLabelNumEdges1 = new javax.swing.JLabel();
        jLabelValNumEdges1 = new javax.swing.JLabel();
        jLabelDiameter1 = new javax.swing.JLabel();
        jLabelValDiam1 = new javax.swing.JLabel();
        jLabelNumConComp1 = new javax.swing.JLabel();
        jLabelValNumConComp1 = new javax.swing.JLabel();
        jLabelMaxSizeConComp1 = new javax.swing.JLabel();
        jLabelValMaxSizeConComp1 = new javax.swing.JLabel();
        jLabelCC1 = new javax.swing.JLabel();
        jLabelValCC1 = new javax.swing.JLabel();
        jLabelAvgDeg1 = new javax.swing.JLabel();
        jLabelValAvgDeg1 = new javax.swing.JLabel();
        jPanel1 = new MyJPanel();
        jButtonConComp1 = new javax.swing.JButton();
        jButtonDelete1 = new javax.swing.JButton();
        jTextFieldDelete1 = new javax.swing.JTextField();
        jLabelDelete1 = new javax.swing.JLabel();
        jLabelFC1 = new javax.swing.JLabel();
        jLabelValFC1 = new javax.swing.JLabel();
        
        jPanelTab1.setPreferredSize(new java.awt.Dimension(800, 480));

        jLabelNumNodes1.setText("Number of Nodes");
        jTextFieldNumNodes1.setText("0");
        jLabelConProb1.setText("Connection Probability");
        jTextFieldConProb1.setText("0.0");

        jButtonGenGraph1.setText("Generate Graph");
        jButtonGenGraph1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenGraph1ActionPerformed(evt);
            }
        });

        jLabelNumEdges1.setText("Number of Edges");
        jLabelValNumEdges1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumEdges1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumEdges1.setText("0");

        jLabelDiameter1.setText("Diameter");
        jLabelValDiam1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValDiam1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValDiam1.setText("0");

        jLabelNumConComp1.setText("Number of Conn. Components");
        jLabelValNumConComp1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumConComp1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumConComp1.setText("0");

        jLabelMaxSizeConComp1.setText("Max Size of a Conn. Component    ");
        jLabelValMaxSizeConComp1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValMaxSizeConComp1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValMaxSizeConComp1.setText("0");

        jLabelCC1.setText("Clustering Coefficient (avg)");
        jLabelValCC1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValCC1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValCC1.setText("0");

        jLabelAvgDeg1.setText("Average Degree (K)");
        jLabelValAvgDeg1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValAvgDeg1.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValAvgDeg1.setText("0");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setPreferredSize(new java.awt.Dimension(480, 480));


        jButtonConComp1.setText("Connected Components");
        jButtonConComp1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConComp1ActionPerformed(evt);
            }
        });

        jButtonDelete1.setText("Delete");
        jButtonDelete1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDelete1ActionPerformed(evt);
            }
        });

        jTextFieldDelete1.setText("0");
        jLabelDelete1.setText("% of Nodes");
        jLabelFC1.setText("1-Fc:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 662, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );
        
        javax.swing.GroupLayout jPanelTab1Layout = new javax.swing.GroupLayout(jPanelTab1);
        jPanelTab1.setLayout(jPanelTab1Layout);
        jPanelTab1Layout.setHorizontalGroup(
            jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelConProb1)
                                .addComponent(jLabelNumNodes1))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jTextFieldNumNodes1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldConProb1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelCC1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValCC1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelMaxSizeConComp1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValMaxSizeConComp1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelNumConComp1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumConComp1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelDiameter1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValDiam1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelNumEdges1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumEdges1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab1Layout.createSequentialGroup()
                            .addComponent(jLabelAvgDeg1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValAvgDeg1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButtonGenGraph1)
                    .addGroup(jPanelTab1Layout.createSequentialGroup()
                        .addComponent(jButtonDelete1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDelete1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelDelete1))
                    .addGroup(jPanelTab1Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabelFC1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelValFC1))
                    .addComponent(jButtonConComp1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE))
        );
        jPanelTab1Layout.setVerticalGroup(
            jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumNodes1)
                    .addComponent(jTextFieldNumNodes1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelConProb1)
                    .addComponent(jTextFieldConProb1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButtonGenGraph1)
                .addGap(51, 51, 51)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdges1)
                    .addComponent(jLabelValNumEdges1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDiameter1)
                    .addComponent(jLabelValDiam1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumConComp1)
                    .addComponent(jLabelValNumConComp1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMaxSizeConComp1)
                    .addComponent(jLabelValMaxSizeConComp1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCC1)
                    .addComponent(jLabelValCC1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelAvgDeg1)
                    .addComponent(jLabelValAvgDeg1))
                .addGap(18, 18, 18)
                .addComponent(jButtonConComp1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonDelete1)
                    .addComponent(jTextFieldDelete1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDelete1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelFC1)
                    .addComponent(jLabelValFC1))
                .addContainerGap(94, Short.MAX_VALUE))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
        );

        jTabbedPaneTop.addTab("Erdos-Renyi", jPanelTab1);
    }

    
    private void Tab2Gui() {
    	
        jPanelTab2 = new javax.swing.JPanel();
        jLabelNumNodes2 = new javax.swing.JLabel();
        jTextFieldNumNodes2 = new javax.swing.JTextField();
        jLabelNumEdgeToSelect2 = new javax.swing.JLabel();
        jTextFieldNumEdgeToSelect2 = new javax.swing.JTextField();
        jButtonGenGraph2 = new javax.swing.JButton();
        jLabelNumEdges2 = new javax.swing.JLabel();
        jLabelValNumEdges2 = new javax.swing.JLabel();
        jLabelDiameter2 = new javax.swing.JLabel();
        jLabelValDiam2 = new javax.swing.JLabel();
        jLabelNumConComp2 = new javax.swing.JLabel();
        jLabelValNumConComp2 = new javax.swing.JLabel();
        jLabelMaxSizeConComp2 = new javax.swing.JLabel();
        jLabelValMaxSizeConComp2 = new javax.swing.JLabel();
        jLabelCC2 = new javax.swing.JLabel();
        jLabelValCC2 = new javax.swing.JLabel();
        jLabelAvgDeg2 = new javax.swing.JLabel();
        jLabelValAvgDeg2 = new javax.swing.JLabel();
        jPanel2 = new MyJPanel();
        jButtonSimulate2 = new javax.swing.JButton();
        jButtonDelete2 = new javax.swing.JButton();
        jTextFieldDelete2 = new javax.swing.JTextField();
        jLabelDelete2 = new javax.swing.JLabel();
        jLabelFC2 = new javax.swing.JLabel();
        jLabelValFC2 = new javax.swing.JLabel();

        jPanelTab2.setPreferredSize(new java.awt.Dimension(800, 480));

        jLabelNumNodes2.setText("Total Number of Nodes");
        jTextFieldNumNodes2.setText("0");
        jLabelNumEdgeToSelect2.setText("Number of Edges to Select");
        jTextFieldNumEdgeToSelect2.setText("0");

        jButtonGenGraph2.setText("Generate Graph");
        jButtonGenGraph2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenGraph2ActionPerformed(evt);
            }
        });

        jLabelNumEdges2.setText("Number of Edges");
        jLabelValNumEdges2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumEdges2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumEdges2.setText("0");

        jLabelDiameter2.setText("Diameter");
        jLabelValDiam2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValDiam2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValDiam2.setText("0");

        jLabelNumConComp2.setText("Number of Conn. Components");
        jLabelValNumConComp2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumConComp2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumConComp2.setText("0");

        jLabelMaxSizeConComp2.setText("Max Size of a Conn. Component    ");
        jLabelValMaxSizeConComp2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValMaxSizeConComp2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValMaxSizeConComp2.setText("0");

        jLabelCC2.setText("Clustering Coefficient (avg)");
        jLabelValCC2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValCC2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValCC2.setText("0");

        jLabelAvgDeg2.setText("Average Degree (K)");
        jLabelValAvgDeg2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValAvgDeg2.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValAvgDeg2.setText("0");

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setPreferredSize(new java.awt.Dimension(480, 480));

        jButtonSimulate2.setText("Simulate");
        jButtonSimulate2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSimulate2ActionPerformed(evt);
            }
        });

        jButtonDelete2.setText("Delete");
        jButtonDelete2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDelete2ActionPerformed(evt);
            }
        });

        jTextFieldDelete2.setText("0");
        jLabelDelete2.setText("% of Nodes");
        jLabelFC2.setText("1-Fc:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 662, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelTab2Layout = new javax.swing.GroupLayout(jPanelTab2);
        jPanelTab2.setLayout(jPanelTab2Layout);
        jPanelTab2Layout.setHorizontalGroup(
            jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelNumEdgeToSelect2)
                                .addComponent(jLabelNumNodes2))
                            .addGap(27, 27, 27)
                            .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jTextFieldNumEdgeToSelect2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldNumNodes2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelCC2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValCC2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelMaxSizeConComp2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValMaxSizeConComp2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelNumConComp2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumConComp2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelDiameter2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValDiam2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelNumEdges2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumEdges2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab2Layout.createSequentialGroup()
                            .addComponent(jLabelAvgDeg2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValAvgDeg2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButtonGenGraph2)
                    .addGroup(jPanelTab2Layout.createSequentialGroup()
                        .addComponent(jButtonDelete2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDelete2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelDelete2))
                    .addGroup(jPanelTab2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabelFC2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelValFC2))
                    .addComponent(jButtonSimulate2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE))
        );
        jPanelTab2Layout.setVerticalGroup(
            jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumNodes2)
                    .addComponent(jTextFieldNumNodes2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdgeToSelect2)
                    .addComponent(jTextFieldNumEdgeToSelect2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButtonGenGraph2)
                .addGap(57, 57, 57)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdges2)
                    .addComponent(jLabelValNumEdges2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDiameter2)
                    .addComponent(jLabelValDiam2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumConComp2)
                    .addComponent(jLabelValNumConComp2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMaxSizeConComp2)
                    .addComponent(jLabelValMaxSizeConComp2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCC2)
                    .addComponent(jLabelValCC2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelAvgDeg2)
                    .addComponent(jLabelValAvgDeg2))
                .addGap(18, 18, 18)
                .addComponent(jButtonSimulate2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonDelete2)
                    .addComponent(jTextFieldDelete2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDelete2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelFC2)
                    .addComponent(jLabelValFC2))
                .addContainerGap(88, Short.MAX_VALUE))
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
        );

        jTabbedPaneTop.addTab("Barabasi-Albert", jPanelTab2);
    }
    
    
    private void Tab3Gui() {
    	
        jPanelTab3 = new javax.swing.JPanel();
        jLabelNumNodes3 = new javax.swing.JLabel();
        jTextFieldNumNodes3 = new javax.swing.JTextField();
        jLabelNumEdgeToSelect3 = new javax.swing.JLabel();
        jTextFieldNumEdgeToSelect3 = new javax.swing.JTextField();
        jButtonGenGraph3 = new javax.swing.JButton();
        jLabelNumEdges3 = new javax.swing.JLabel();
        jLabelValNumEdges3 = new javax.swing.JLabel();
        jLabelDiameter3 = new javax.swing.JLabel();
        jLabelValDiam3 = new javax.swing.JLabel();
        jLabelNumConComp3 = new javax.swing.JLabel();
        jLabelValNumConComp3 = new javax.swing.JLabel();
        jLabelMaxSizeConComp3 = new javax.swing.JLabel();
        jLabelValMaxSizeConComp3 = new javax.swing.JLabel();
        jLabelCC3 = new javax.swing.JLabel();
        jLabelValCC3 = new javax.swing.JLabel();
        jLabelAvgDeg3 = new javax.swing.JLabel();
        jLabelValAvgDeg3 = new javax.swing.JLabel();
        jPanel3 = new MyJPanel();
        jButtonSimulate3 = new javax.swing.JButton();
        jLabelValFC3 = new javax.swing.JLabel();
        jLabelFC3 = new javax.swing.JLabel();
        jLabelDelete3 = new javax.swing.JLabel();
        jTextFieldDelete3 = new javax.swing.JTextField();
        jButtonDelete3 = new javax.swing.JButton();
        
        jPanelTab3.setPreferredSize(new java.awt.Dimension(800, 480));

        jLabelNumNodes3.setText("Total Number of Nodes");
        jTextFieldNumNodes3.setText("0");
        jLabelNumEdgeToSelect3.setText("Number of Edges to Select");
        jTextFieldNumEdgeToSelect3.setText("0");
        jButtonGenGraph3.setText("Generate Graph");
        jButtonGenGraph3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenGraph3ActionPerformed(evt);
            }
        });

        jLabelNumEdges3.setText("Number of Edges");
        jLabelValNumEdges3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumEdges3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumEdges3.setText("0");

        jLabelDiameter3.setText("Diameter");
        jLabelValDiam3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValDiam3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValDiam3.setText("0");

        jLabelNumConComp3.setText("Number of Conn. Components");
        jLabelValNumConComp3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumConComp3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumConComp3.setText("0");

        jLabelMaxSizeConComp3.setText("Max Size of a Conn. Component    ");
        jLabelValMaxSizeConComp3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValMaxSizeConComp3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValMaxSizeConComp3.setText("0");

        jLabelCC3.setText("Clustering Coefficient (avg)");
        jLabelValCC3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValCC3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValCC3.setText("0");

        jLabelAvgDeg3.setText("Average Degree (K)");
        jLabelValAvgDeg3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValAvgDeg3.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValAvgDeg3.setText("0");

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setPreferredSize(new java.awt.Dimension(480, 480));

        jButtonSimulate3.setText("Simulate");
        jButtonSimulate3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSimulate3ActionPerformed(evt);
            }
        });

        jLabelFC3.setText("1-Fc:");
        jLabelDelete3.setText("% of Nodes");
        jTextFieldDelete3.setText("0");

        jButtonDelete3.setText("Delete");
        jButtonDelete3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDelete3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 662, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelTab3Layout = new javax.swing.GroupLayout(jPanelTab3);
        jPanelTab3.setLayout(jPanelTab3Layout);
        jPanelTab3Layout.setHorizontalGroup(
            jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabelNumEdgeToSelect3)
                                .addComponent(jLabelNumNodes3))
                            .addGap(27, 27, 27)
                            .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jTextFieldNumEdgeToSelect3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jTextFieldNumNodes3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelCC3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValCC3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelMaxSizeConComp3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValMaxSizeConComp3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelNumConComp3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumConComp3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelDiameter3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValDiam3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelNumEdges3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumEdges3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab3Layout.createSequentialGroup()
                            .addComponent(jLabelAvgDeg3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValAvgDeg3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButtonGenGraph3)
                    .addComponent(jButtonSimulate3)
                    .addGroup(jPanelTab3Layout.createSequentialGroup()
                        .addComponent(jButtonDelete3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldDelete3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelDelete3))
                    .addGroup(jPanelTab3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jLabelFC3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelValFC3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE))
        );
        jPanelTab3Layout.setVerticalGroup(
            jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumNodes3)
                    .addComponent(jTextFieldNumNodes3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdgeToSelect3)
                    .addComponent(jTextFieldNumEdgeToSelect3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jButtonGenGraph3)
                .addGap(57, 57, 57)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdges3)
                    .addComponent(jLabelValNumEdges3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDiameter3)
                    .addComponent(jLabelValDiam3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumConComp3)
                    .addComponent(jLabelValNumConComp3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMaxSizeConComp3)
                    .addComponent(jLabelValMaxSizeConComp3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCC3)
                    .addComponent(jLabelValCC3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelAvgDeg3)
                    .addComponent(jLabelValAvgDeg3))
                .addGap(18, 18, 18)
                .addComponent(jButtonSimulate3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonDelete3)
                    .addComponent(jTextFieldDelete3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDelete3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelFC3)
                    .addComponent(jLabelValFC3))
                .addContainerGap(88, Short.MAX_VALUE))
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
        );

        jTabbedPaneTop.addTab("Preferential Attachment", jPanelTab3);
    }

   
    private void Tab4Gui() {
    	
        jPanelTab4 = new javax.swing.JPanel();
        jLabelLamda4 = new javax.swing.JLabel();
        jTextFieldLamda4 = new javax.swing.JTextField();
        jButtonGenGraph4 = new javax.swing.JButton();
        jLabelNumEdges4 = new javax.swing.JLabel();
        jLabelValNumEdges4 = new javax.swing.JLabel();
        jLabelDiameter4 = new javax.swing.JLabel();
        jLabelValDiam4 = new javax.swing.JLabel();
        jLabelNumConComp4 = new javax.swing.JLabel();
        jLabelValNumConComp4 = new javax.swing.JLabel();
        jLabelMaxSizeConComp4 = new javax.swing.JLabel();
        jLabelValMaxSizeConComp4 = new javax.swing.JLabel();
        jLabelCC4 = new javax.swing.JLabel();
        jLabelValCC4 = new javax.swing.JLabel();
        jLabelAvgDeg4 = new javax.swing.JLabel();
        jLabelValAvgDeg4 = new javax.swing.JLabel();
        jPanel4 = new MyJPanel();
        jButtonPlotView4 = new javax.swing.JButton();
        
        jPanelTab4.setPreferredSize(new java.awt.Dimension(800, 480));

        jLabelLamda4.setText("Degree Exponent (\u03BB)");
        jTextFieldLamda4.setText("0");

        jButtonGenGraph4.setText("Generate Graph");
        jButtonGenGraph4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGenGraph4ActionPerformed(evt);
            }
        });

        jLabelNumEdges4.setText("Number of Edges");
        jLabelValNumEdges4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumEdges4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumEdges4.setText("0");

        jLabelDiameter4.setText("Diameter");
        jLabelValDiam4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValDiam4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValDiam4.setText("0");

        jLabelNumConComp4.setText("Number of Conn. Components");
        jLabelValNumConComp4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValNumConComp4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValNumConComp4.setText("0");

        jLabelMaxSizeConComp4.setText("Max Size of a Conn. Component    ");
        jLabelValMaxSizeConComp4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValMaxSizeConComp4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValMaxSizeConComp4.setText("0");

        jLabelCC4.setText("Clustering Coefficient (avg)");
        jLabelValCC4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValCC4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValCC4.setText("0");

        jLabelAvgDeg4.setText("Average Degree (K)");
        jLabelValAvgDeg4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabelValAvgDeg4.setForeground(new java.awt.Color(153, 0, 0));
        jLabelValAvgDeg4.setText("0");

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setPreferredSize(new java.awt.Dimension(480, 480));

        jButtonPlotView4.setText("Structured View");
        jButtonPlotView4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPlotView4ActionPerformed(evt);
            }
        });


        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 662, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );
        
        javax.swing.GroupLayout jPanelTab4Layout = new javax.swing.GroupLayout(jPanelTab4);
        jPanelTab4.setLayout(jPanelTab4Layout);
        jPanelTab4Layout.setHorizontalGroup(
            jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelLamda4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jTextFieldLamda4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelCC4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValCC4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelMaxSizeConComp4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValMaxSizeConComp4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelNumConComp4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumConComp4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelDiameter4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValDiam4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelNumEdges4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValNumEdges4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanelTab4Layout.createSequentialGroup()
                            .addComponent(jLabelAvgDeg4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelValAvgDeg4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jButtonPlotView4)
                    .addComponent(jButtonGenGraph4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 666, Short.MAX_VALUE))
        );
        jPanelTab4Layout.setVerticalGroup(
            jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTab4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelLamda4)
                    .addComponent(jTextFieldLamda4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(48, 48, 48)
                .addComponent(jButtonGenGraph4)
                .addGap(53, 53, 53)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumEdges4)
                    .addComponent(jLabelValNumEdges4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDiameter4)
                    .addComponent(jLabelValDiam4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNumConComp4)
                    .addComponent(jLabelValNumConComp4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMaxSizeConComp4)
                    .addComponent(jLabelValMaxSizeConComp4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCC4)
                    .addComponent(jLabelValCC4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelTab4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelAvgDeg4)
                    .addComponent(jLabelValAvgDeg4))
                .addGap(18, 18, 18)
                .addComponent(jButtonPlotView4)
                .addContainerGap(142, Short.MAX_VALUE))
            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
        );

        jTabbedPaneTop.addTab("Scale Free (Deterministic)", jPanelTab4);
    }

    
    /** 
     * This method is called from within the constructor to
     * initialize the form.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        
    	setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Random Graph");
        setMinimumSize(new java.awt.Dimension(800, 480));
        jTabbedPaneTop = new javax.swing.JTabbedPane();
        jTabbedPaneTop.setPreferredSize(new java.awt.Dimension(800, 460));
    	
    	Tab1Gui();
    	Tab4Gui();
    	Tab3Gui();
    	Tab2Gui();

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneTop, javax.swing.GroupLayout.DEFAULT_SIZE, 937, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPaneTop, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>

	private void jButtonGenGraph1ActionPerformed(java.awt.event.ActionEvent evt) {
	    int nodeNum;
	    double conProb;
	
	    String strNodeNum = jTextFieldNumNodes1.getText();
	    String strConProb = jTextFieldConProb1.getText();
	    
	    try {nodeNum = Integer.parseInt(strNodeNum);}
	    catch (NumberFormatException e) {nodeNum = 0;}
	    
	    try {conProb = Double.parseDouble(strConProb);}
	    catch (NumberFormatException e) {conProb = 0.0;}
	
	    boolean validInput = isValidInput(nodeNum, 3, 3, conProb);
	       
	    if( !validInput ) {
	        jTextFieldNumNodes1.setText("0");
	        jTextFieldConProb1.setText("0.0");
	        jLabelValNumEdges1.setText("0");
	        jLabelValDiam1.setText("0");
	        jLabelValNumConComp1.setText("0");
	        jLabelValMaxSizeConComp1.setText("0");
	        jLabelValCC1.setText("0");
	        jLabelValAvgDeg1.setText("0");
	        jLabelValFC1.setText("");
	        jTextFieldDelete1.setText("0");
    	return;
	    }
	
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";
	 
	    MyGraph erGraph = new ErdosRenyiGraph(nodeNum, conProb);
	    erGraph.setDelay(MAX_DELAY);
	    erGraph.generateGraph();
	    erGraph.setDrawConComp(false);
	    
	    edgeNum = erGraph.numEdges;
	    diam = erGraph.getDiameter();
	    numConComp = erGraph.getNumberOfConnectedComponents();
	    maxSzConComp = erGraph.getMaximumSizeofConnectedComponents();
	    avgClusCo = erGraph.getAverageClusteringCoefficient();
	    if(erGraph.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)erGraph.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0 - (double)1/avgDeg);
		DecimalFormat dfCp = new DecimalFormat("#.########");
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes1.setText(Integer.toString(nodeNum));
	    jTextFieldConProb1.setText(dfCp.format(conProb));
	    jLabelValNumEdges1.setText(Integer.toString(edgeNum));
	    jLabelValDiam1.setText(Integer.toString(diam));
	    jLabelValNumConComp1.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp1.setText(Integer.toString(maxSzConComp));
	    jLabelValCC1.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg1.setText(dfCc.format(avgDeg));
	    jLabelValFC1.setText(fc);

	
	    jPanel1.setMyGraph(erGraph);
	    jPanel1.repaint();
	    writeInfo(erGraph, lw);
	}

	private void jButtonConComp1ActionPerformed(java.awt.event.ActionEvent evt) {
		MyGraph gr = jPanel1.getMyGraph();
		if(gr == null)
			return;
		gr.alterDrawConComp();
		jPanel1.repaint();
	}
	
	
	private void jButtonGenGraph2ActionPerformed(java.awt.event.ActionEvent evt) {
		int nodeNum, edgeToSelect;
	    
	    String strNodeNum = jTextFieldNumNodes2.getText();
	    String strEdgeToSelect = jTextFieldNumEdgeToSelect2.getText();
	    
	    try {nodeNum = Integer.parseInt(strNodeNum);}
	    catch (NumberFormatException e) {nodeNum = 0;}
	    
	    try {edgeToSelect = Integer.parseInt(strEdgeToSelect);}
	    catch (NumberFormatException e) {edgeToSelect = 0;}
	    
	    boolean validInput = isValidInput(nodeNum, INIT_NODE_NUM, edgeToSelect, 0.5);
	    
	    if(nodeNum < INIT_NODE_NUM)
	    	validInput = false;

	    if( !validInput ) {
	        jTextFieldNumNodes2.setText("0");
	        jTextFieldNumEdgeToSelect2.setText("0");
	        jLabelValNumEdges2.setText("0");
	        jLabelValDiam2.setText("0");
	        jLabelValNumConComp2.setText("0");
	        jLabelValMaxSizeConComp2.setText("0");
	        jLabelValCC2.setText("0");
	        jLabelValAvgDeg2.setText("0");
	        jLabelValFC2.setText("");
	        jTextFieldDelete2.setText("0");
	    	return;
	    }
	    	
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";

	
	    MyGraph baGraph = new ScaleFreeBAGraph(nodeNum, 3, edgeToSelect);
	  	baGraph.setDelay(MAX_DELAY);
		baGraph.generateGraph();
	    edgeNum = baGraph.numEdges;
	    diam = baGraph.getDiameter();
	    numConComp = baGraph.getNumberOfConnectedComponents();
	    maxSzConComp = baGraph.getMaximumSizeofConnectedComponents();
	    avgClusCo = baGraph.getAverageClusteringCoefficient();
	    if(baGraph.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)baGraph.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0 - (double)1/avgDeg);
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes2.setText(Integer.toString(nodeNum));
	    jTextFieldNumEdgeToSelect2.setText(Integer.toString(edgeToSelect));
	    jLabelValNumEdges2.setText(Integer.toString(edgeNum));
	    jLabelValDiam2.setText(Integer.toString(diam));
	    jLabelValNumConComp2.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp2.setText(Integer.toString(maxSzConComp));
	    jLabelValCC2.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg2.setText(dfCc.format(avgDeg));
	    jLabelValFC2.setText(fc);
	    
	    jButtonSimulate2.setEnabled(true);
	    jPanel2.setMyGraph(baGraph);
	    jPanel2.repaint();
	    writeInfo(baGraph, lw);
	}
	
	private void jButtonSimulate2ActionPerformed(java.awt.event.ActionEvent evt) {
		ScaleFreeBAGraph gr = (ScaleFreeBAGraph)jPanel2.getMyGraph();
		if(gr == null)
			return;
		gr.alterSimulateGraph();
		
		while( gr.contSimulation ) {
			jPanel2.update(jPanel2.getGraphics());
			
			try {
				Thread.sleep(PANEL_UPDATE_DELAY);
			}
			catch (InterruptedException e) {
				System.out.println(e.getStackTrace());
				return;
			}
		}
	
		jPanel2.repaint();
	}
	
	
	private void jButtonGenGraph3ActionPerformed(java.awt.event.ActionEvent evt) {
	    int nodeNum, edgeToSelect;
	    
	    String strNodeNum = jTextFieldNumNodes3.getText();
	    String strEdgeToSelect = jTextFieldNumEdgeToSelect3.getText();
	    
	    try {nodeNum = Integer.parseInt(strNodeNum);}
	    catch (NumberFormatException e) {nodeNum = 0;}
	    
	    try {edgeToSelect = Integer.parseInt(strEdgeToSelect);}
	    catch (NumberFormatException e) {edgeToSelect = 0;}
	    
	    boolean validInput = isValidInput(nodeNum, INIT_NODE_NUM, edgeToSelect, 0.5);
	    
	    if(nodeNum < INIT_NODE_NUM)
	    	validInput = false;

	    if( !validInput ) {
	        jTextFieldNumNodes3.setText("0");
	        jTextFieldNumEdgeToSelect3.setText("0");
	        jLabelValNumEdges3.setText("0");
	        jLabelValDiam3.setText("0");
	        jLabelValNumConComp3.setText("0");
	        jLabelValMaxSizeConComp3.setText("0");
	        jLabelValCC3.setText("0");
	        jLabelValAvgDeg3.setText("0");
	        jLabelValFC3.setText("");
	        jTextFieldDelete3.setText("0");
	    	return;
	    }
	    	
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";

	
	    MyGraph paGraph = new PrefAttachGraph(nodeNum, 3, edgeToSelect);
	    paGraph.setDelay(MAX_DELAY);
	    paGraph.generateGraph();
	    edgeNum = paGraph.numEdges;
	    diam = paGraph.getDiameter();
	    numConComp = paGraph.getNumberOfConnectedComponents();
	    maxSzConComp = paGraph.getMaximumSizeofConnectedComponents();
	    avgClusCo = paGraph.getAverageClusteringCoefficient();
	    if(paGraph.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)paGraph.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0-(double)1/avgDeg);
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes3.setText(Integer.toString(nodeNum));
	    jTextFieldNumEdgeToSelect3.setText(Integer.toString(edgeToSelect));
	    jLabelValNumEdges3.setText(Integer.toString(edgeNum));
	    jLabelValDiam3.setText(Integer.toString(diam));
	    jLabelValNumConComp3.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp3.setText(Integer.toString(maxSzConComp));
	    jLabelValCC3.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg3.setText(dfCc.format(avgDeg));
	    jLabelValFC3.setText(fc);

	    jButtonSimulate3.setEnabled(true);
	    jPanel3.setMyGraph(paGraph);
	    jPanel3.repaint();
	    writeInfo(paGraph, lw);
	}
	
	private void jButtonSimulate3ActionPerformed(java.awt.event.ActionEvent evt) {
		PrefAttachGraph gr = (PrefAttachGraph)jPanel3.getMyGraph();
		if(gr == null)
			return;
		gr.alterSimulateGraph();
		
		while( gr.contSimulation ) {
			jPanel3.update(jPanel3.getGraphics());
			
			try {
				Thread.sleep(PANEL_UPDATE_DELAY);
			}
			catch (InterruptedException e) {
				System.out.println(e.getStackTrace());
				return;
			}
		}
	
		jPanel3.repaint();
	}


	private void jButtonGenGraph4ActionPerformed(java.awt.event.ActionEvent evt) {
	    double lambda;
	    boolean validInput = true;
	    
	    String lambdaStr = jTextFieldLamda4.getText();
	    
	    try {lambda = Double.parseDouble(lambdaStr);}
	    catch (NumberFormatException e) {lambda = -1.0;}
	    
	    if(lambda < 1.0 || lambda > 1.6)
	    	validInput = false;
	    
	    if( !validInput ) {
	        jTextFieldLamda4.setText("0");
	        jLabelValNumEdges4.setText("0");
	        jLabelValDiam4.setText("0");
	        jLabelValNumConComp4.setText("0");
	        jLabelValMaxSizeConComp4.setText("0");
	        jLabelValCC4.setText("0");
	        jLabelValAvgDeg4.setText("0");
	        jPanel1.removeAll();
	    	return;
	    }
	    	
	    int ind, k;
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    double lnk[] = new double[SCALEFREE_DETERMINISTIC_MAX_K+1];
	    double dif, minDif = 1000000000.0;
	    
	    k = 2;
	    for(ind=2; ind<SCALEFREE_DETERMINISTIC_MAX_K; ind++) {
	    	lnk[ind] = Math.log(ind+1)/Math.log(ind);
	    	dif = Math.abs(lnk[ind]-lambda);
	    	
	    	if(dif < minDif) {
	    		minDif = dif;
	    		k = ind;
	    	}
	    }
	
	    MyGraph sfGraph = new ScaleFreeDeterministicGraph(k, SCALEFREE_DETERMINISTIC_MAX_NODE);
	    sfGraph.setDelay(MAX_DELAY);
	    sfGraph.setDrawStructuredView(false);
		jButtonPlotView4.setText("Structured View");
	    sfGraph.generateGraph();

	    edgeNum = sfGraph.numEdges;
	    diam = sfGraph.getDiameter();
	    numConComp = sfGraph.getNumberOfConnectedComponents();
	    maxSzConComp = sfGraph.getMaximumSizeofConnectedComponents();
	    avgClusCo = sfGraph.getAverageClusteringCoefficient();
	    if(sfGraph.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)sfGraph.numNodes; 
	    DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldLamda4.setText(Double.toString(lambda));
	    jLabelValNumEdges4.setText(Integer.toString(edgeNum));
	    jLabelValDiam4.setText(Integer.toString(diam));
	    jLabelValNumConComp4.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp4.setText(Integer.toString(maxSzConComp));
	    jLabelValCC4.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg4.setText(dfCc.format(avgDeg));
	
	    jPanel4.setMyGraph(sfGraph);
	    jPanel4.repaint();
	    writeInfo(sfGraph, lw);
	}
	
	private void jButtonPlotView4ActionPerformed(java.awt.event.ActionEvent evt) {                                                 
		MyGraph gr = jPanel4.getMyGraph();
		if(gr == null)
			return;
		gr.alterDrawStructuredView();
		
		String buttonName = jButtonPlotView4.getText();
		
		if(buttonName.startsWith("Random"))
			jButtonPlotView4.setText("Structured View");
		else
			jButtonPlotView4.setText("Random View");
			
		jPanel4.repaint();
	}                                                


	private void jButtonDelete1ActionPerformed(java.awt.event.ActionEvent evt) {
		int delVal = 0;
		String delValStr = jTextFieldDelete1.getText();
		
	    try {delVal = Integer.parseInt(delValStr);}
	    catch (NumberFormatException e) {delVal = 0;}
	    
		MyGraph gr = jPanel1.getMyGraph();
		if(gr == null)
			delVal = 0;
		
	    if(delVal <= 0 || delVal > MAX_NODE_DELETE) {
	    	jTextFieldDelete1.setText("0");
	    	return;
	    }
		
		if( !gr.deleteNodes(delVal) )
			return;
		
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";
	 
	    gr.setDrawConComp(false);
	    
	    edgeNum = gr.numEdges;
	    diam = gr.getDiameter();
	    numConComp = gr.getNumberOfConnectedComponents();
	    maxSzConComp = gr.getMaximumSizeofConnectedComponents();
	    avgClusCo = gr.getAverageClusteringCoefficient();
	    if(gr.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)gr.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0 - (double)1/avgDeg);
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes1.setText(Integer.toString(gr.numNodes));
	    jLabelValNumEdges1.setText(Integer.toString(edgeNum));
	    jLabelValDiam1.setText(Integer.toString(diam));
	    jLabelValNumConComp1.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp1.setText(Integer.toString(maxSzConComp));
	    jLabelValCC1.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg1.setText(dfCc.format(avgDeg));
	    jLabelValFC1.setText(fc);

	    jPanel1.repaint();
	}

	private void jButtonDelete2ActionPerformed(java.awt.event.ActionEvent evt) {
		int delVal = 0;
		String delValStr = jTextFieldDelete2.getText();
		
	    try {delVal = Integer.parseInt(delValStr);}
	    catch (NumberFormatException e) {delVal = 0;}
	    
		MyGraph gr = jPanel2.getMyGraph();
		if(gr == null)
			delVal = 0;
		
	    if(delVal <= 0 || delVal > MAX_NODE_DELETE) {
	    	jTextFieldDelete2.setText("0");
	    	return;
	    }
		
		if( !gr.deleteNodes(delVal) )
			return;
		
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";
	 
	    gr.setDrawConComp(false);
	    
	    edgeNum = gr.numEdges;
	    diam = gr.getDiameter();
	    numConComp = gr.getNumberOfConnectedComponents();
	    maxSzConComp = gr.getMaximumSizeofConnectedComponents();
	    avgClusCo = gr.getAverageClusteringCoefficient();
	    if(gr.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)gr.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0 - (double)1/avgDeg);
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes2.setText(Integer.toString(gr.numNodes));
	    jLabelValNumEdges2.setText(Integer.toString(edgeNum));
	    jLabelValDiam2.setText(Integer.toString(diam));
	    jLabelValNumConComp2.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp2.setText(Integer.toString(maxSzConComp));
	    jLabelValCC2.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg2.setText(dfCc.format(avgDeg));
	    jLabelValFC2.setText(fc);
	    
	    jButtonSimulate2.setEnabled(false);

	    jPanel2.repaint();
	}
	
	private void jButtonDelete3ActionPerformed(java.awt.event.ActionEvent evt) {
		int delVal = 0;
		String delValStr = jTextFieldDelete3.getText();
		
	    try {delVal = Integer.parseInt(delValStr);}
	    catch (NumberFormatException e) {delVal = 0;}
	    
		MyGraph gr = jPanel3.getMyGraph();
		if(gr == null)
			delVal = 0;
		
	    if(delVal <= 0 || delVal > MAX_NODE_DELETE) {
	    	jTextFieldDelete3.setText("0");
	    	return;
	    }
		
		if( !gr.deleteNodes(delVal) )
			return;
		
	    int edgeNum = 0;
	    int diam = 0;
	    int numConComp = 0;
	    int maxSzConComp = 0;
	    double avgClusCo = 0.0;
	    double avgDeg = 0.0;
	    String fc = "";
	 
	    gr.setDrawConComp(false);
	    
	    edgeNum = gr.numEdges;
	    diam = gr.getDiameter();
	    numConComp = gr.getNumberOfConnectedComponents();
	    maxSzConComp = gr.getMaximumSizeofConnectedComponents();
	    avgClusCo = gr.getAverageClusteringCoefficient();
	    if(gr.numNodes != 0)
	    	avgDeg = (double)(edgeNum*2)/(double)gr.numNodes; 
		if(avgDeg != 0.0)
			fc = Double.toString(1.0 - (double)1/avgDeg);
		DecimalFormat dfCc = new DecimalFormat("#.########");
	    
	    jTextFieldNumNodes3.setText(Integer.toString(gr.numNodes));
	    jLabelValNumEdges3.setText(Integer.toString(edgeNum));
	    jLabelValDiam3.setText(Integer.toString(diam));
	    jLabelValNumConComp3.setText(Integer.toString(numConComp));
	    jLabelValMaxSizeConComp3.setText(Integer.toString(maxSzConComp));
	    jLabelValCC3.setText(dfCc.format(avgClusCo));
	    jLabelValAvgDeg3.setText(dfCc.format(avgDeg));
	    jLabelValFC3.setText(fc);
	    
	    jButtonSimulate3.setEnabled(false);

	    jPanel3.repaint();
	}

	private void writeInfo(MyGraph gr, LogWriter lw) {
		if(gr == null)
			return;
		
	    gr.writeInfo(lw, LogType.Summary);
	    gr.writeInfo(lw, LogType.DegreeDistribution);
	    
	    if(gr instanceof PrefAttachGraph || gr instanceof ScaleFreeBAGraph)
	    	gr.writeInfo(lw, LogType.AgeDegreeRelation);
	    return;
	}

	private boolean isValidInput(int nodeNum, int initNodeNum, int edgeToSelect, double conProb) {
	    
		if(nodeNum<0 || nodeNum>MAX_NUM_OF_NODES)
	        return false;
	    
	    if(initNodeNum<2 || initNodeNum>MAX_NUM_OF_INIT_NODES)
	        return false;
	    
	    if(edgeToSelect<0 || edgeToSelect>MAX_NUM_OF_EDGE_TO_SELECT)
	        return false;
	    
	    if( (initNodeNum*(initNodeNum-1))/2 < edgeToSelect )
	        return false;

	    if(conProb<0.0 || conProb>1.0)
	        return false;

	    return true;
	}
	
	public static void runApp() {
    	try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException e) {
            java.util.logging.Logger.getLogger(RandomGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, e);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RandomGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RandomGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RandomGraph.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

        lw = new LogWriter(LOG_ROOT_DIR);


        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new RandomGraph().setVisible(true);
            }
        });
	}

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        runApp();
    }
    
    // Variables declaration - do not modify
    private javax.swing.JButton jButtonConComp1;
    private javax.swing.JButton jButtonDelete1;
    private javax.swing.JButton jButtonDelete2;
    private javax.swing.JButton jButtonDelete3;
    private javax.swing.JButton jButtonGenGraph1;
    private javax.swing.JButton jButtonGenGraph2;
    private javax.swing.JButton jButtonGenGraph3;
    private javax.swing.JButton jButtonGenGraph4;
    private javax.swing.JButton jButtonPlotView4;
    private javax.swing.JButton jButtonSimulate2;
    private javax.swing.JButton jButtonSimulate3;
    private javax.swing.JLabel jLabelAvgDeg1;
    private javax.swing.JLabel jLabelAvgDeg2;
    private javax.swing.JLabel jLabelAvgDeg3;
    private javax.swing.JLabel jLabelAvgDeg4;
    private javax.swing.JLabel jLabelCC1;
    private javax.swing.JLabel jLabelCC2;
    private javax.swing.JLabel jLabelCC3;
    private javax.swing.JLabel jLabelCC4;
    private javax.swing.JLabel jLabelConProb1;
    private javax.swing.JLabel jLabelDelete1;
    private javax.swing.JLabel jLabelDelete2;
    private javax.swing.JLabel jLabelDelete3;
    private javax.swing.JLabel jLabelDiameter1;
    private javax.swing.JLabel jLabelDiameter2;
    private javax.swing.JLabel jLabelDiameter3;
    private javax.swing.JLabel jLabelDiameter4;
    private javax.swing.JLabel jLabelFC1;
    private javax.swing.JLabel jLabelFC2;
    private javax.swing.JLabel jLabelFC3;
    private javax.swing.JLabel jLabelLamda4;
    private javax.swing.JLabel jLabelMaxSizeConComp1;
    private javax.swing.JLabel jLabelMaxSizeConComp2;
    private javax.swing.JLabel jLabelMaxSizeConComp3;
    private javax.swing.JLabel jLabelMaxSizeConComp4;
    private javax.swing.JLabel jLabelNumConComp1;
    private javax.swing.JLabel jLabelNumConComp2;
    private javax.swing.JLabel jLabelNumConComp3;
    private javax.swing.JLabel jLabelNumConComp4;
    private javax.swing.JLabel jLabelNumEdgeToSelect2;
    private javax.swing.JLabel jLabelNumEdgeToSelect3;
    private javax.swing.JLabel jLabelNumEdges1;
    private javax.swing.JLabel jLabelNumEdges2;
    private javax.swing.JLabel jLabelNumEdges3;
    private javax.swing.JLabel jLabelNumEdges4;
    private javax.swing.JLabel jLabelNumNodes1;
    private javax.swing.JLabel jLabelNumNodes2;
    private javax.swing.JLabel jLabelNumNodes3;
    private javax.swing.JLabel jLabelValAvgDeg1;
    private javax.swing.JLabel jLabelValAvgDeg2;
    private javax.swing.JLabel jLabelValAvgDeg3;
    private javax.swing.JLabel jLabelValAvgDeg4;
    private javax.swing.JLabel jLabelValCC1;
    private javax.swing.JLabel jLabelValCC2;
    private javax.swing.JLabel jLabelValCC3;
    private javax.swing.JLabel jLabelValCC4;
    private javax.swing.JLabel jLabelValDiam1;
    private javax.swing.JLabel jLabelValDiam2;
    private javax.swing.JLabel jLabelValDiam3;
    private javax.swing.JLabel jLabelValDiam4;
    private javax.swing.JLabel jLabelValFC1;
    private javax.swing.JLabel jLabelValFC2;
    private javax.swing.JLabel jLabelValFC3;
    private javax.swing.JLabel jLabelValMaxSizeConComp1;
    private javax.swing.JLabel jLabelValMaxSizeConComp2;
    private javax.swing.JLabel jLabelValMaxSizeConComp3;
    private javax.swing.JLabel jLabelValMaxSizeConComp4;
    private javax.swing.JLabel jLabelValNumConComp1;
    private javax.swing.JLabel jLabelValNumConComp2;
    private javax.swing.JLabel jLabelValNumConComp3;
    private javax.swing.JLabel jLabelValNumConComp4;
    private javax.swing.JLabel jLabelValNumEdges1;
    private javax.swing.JLabel jLabelValNumEdges2;
    private javax.swing.JLabel jLabelValNumEdges3;
    private javax.swing.JLabel jLabelValNumEdges4;
    //private javax.swing.JPanel jPanel1;
    //private javax.swing.JPanel jPanel2;
    //private javax.swing.JPanel jPanel3;
    //private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanelTab1;
    private javax.swing.JPanel jPanelTab2;
    private javax.swing.JPanel jPanelTab3;
    private javax.swing.JPanel jPanelTab4;
    private javax.swing.JTabbedPane jTabbedPaneTop;
    private javax.swing.JTextField jTextFieldConProb1;
    private javax.swing.JTextField jTextFieldDelete1;
    private javax.swing.JTextField jTextFieldDelete2;
    private javax.swing.JTextField jTextFieldDelete3;
    private javax.swing.JTextField jTextFieldLamda4;
    private javax.swing.JTextField jTextFieldNumEdgeToSelect2;
    private javax.swing.JTextField jTextFieldNumEdgeToSelect3;
    private javax.swing.JTextField jTextFieldNumNodes1;
    private javax.swing.JTextField jTextFieldNumNodes2;
    private javax.swing.JTextField jTextFieldNumNodes3;
    // End of variables declaration
    
    private MyJPanel jPanel1;
    private MyJPanel jPanel2;
    private MyJPanel jPanel3;
    private MyJPanel jPanel4;
    
    private static LogWriter lw;
    private static String LOG_ROOT_DIR = "c:/";
    private int INIT_NODE_NUM = 3;
    private int MAX_NODE_DELETE = 100;
    private int MAX_NUM_OF_NODES = 1000;
    private int SCALEFREE_DETERMINISTIC_MAX_NODE = 200;
    private int SCALEFREE_DETERMINISTIC_MAX_K = 10;
    private int MAX_NUM_OF_INIT_NODES = 5;
    private int MAX_NUM_OF_EDGE_TO_SELECT = 5;
    private int MAX_DELAY = 1000;
    private int PANEL_UPDATE_DELAY = 20;
}
